package com.nuoniu.sibanyun.mapper.erp.in;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nuoniu.sibanyun.entity.dto.VInventoryCheckMainSearchDto;
import com.nuoniu.sibanyun.entity.erp.in.VInventoryCheckMain;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 小啊刚
 * @since 2021-05-19
 */
public interface VInventoryCheckMainMapper extends BaseMapper<VInventoryCheckMain> {

    @Select("select voucher_code from scw_count where date_format(create_date, #{dateStr})=date_format(now(), #{dateStr}) and company_id=#{companyId} order by create_date desc limit 1")
    String getCode(Integer companyId,  String dateStr);


    VInventoryCheckMain getLastId(Integer companyId, Integer accountId,boolean isLossOrGain);

    VInventoryCheckMain getFirstId(Integer companyId,Integer accountId,boolean isLossOrGain);

    VInventoryCheckMain getPreId(Integer companyId,Integer accountId,Long currentId,boolean isLossOrGain);

    VInventoryCheckMain getNextId(Integer companyId,Integer accountId,Long currentId,boolean isLossOrGain);







    Page<VInventoryCheckMain> pageVInventoryCheckMain(Page page, Integer companyId,@Param("dto") VInventoryCheckMainSearchDto inventoryCheckMainSearchDto);

    @Update("UPDATE scw_count SET is_generate_other_in_out = #{isGenerateOtherInOut} WHERE id = #{id}")
    void updateIsGenerateOtherInOut(Long id,boolean isGenerateOtherInOut);


}
